export interface Dt {
  API_BASE: string
  selectDir: () => Promise<string | undefined>
  selectFile: () => Promise<string | undefined>
  getNginxInfo: () => Promise<NginxInfo[]>
  getNginxInfoById: (id: string) => Promise<NginxInfo>
  saveNginxInfo: <T>(n: NginxInfo) => Promise<ResponseEntity<T>>
  delNginxInfo: <T>(id: string) => Promise<ResponseEntity<T>>
  saveNginxDetail: <T>(data: NginxConfig) => Promise<ResponseEntity<T>>
  testConfig: (id: string) => Promise<ResponseEntity<never>>
  startNginx: (id: string) => Promise<ResponseEntity<never>>
  stopNginx: (id: string) => Promise<ResponseEntity<never>>
  reloadNginx: (id: string) => Promise<ResponseEntity<never>>
}

export interface NginxInfo {
  id?: string
  name: string
  workDir: string
  execPath: string
  createDate?: string
  updateDate?: string
  configDetail?: NginxConfig
}

export interface NginxConfig {
  id: string
  http?: HttpConfigDto
  stream?: StreamConfigDto
  basicConfigs?: BasicConfig[]
}
export interface ResponseEntity<T> {
  code: number
  data?: T
  msg?: string
}


export interface HttpConfigDto {
  basicConfigs?: BasicConfig[]
  serverConfig?: ServerConfig[]
  upstreamConfig?: HttpStreamConfig[]
}
export interface StreamConfigDto {
  basicConfigs?: BasicConfig[]
  serverConfig?: StreamServerConfig[]
  upstreamConfig?: HttpStreamConfig[]
}
export interface BasicConfig {
  code: string;
  value: string;
}

export interface ServerConfig {
  port: number;
  server: string;
  basicConfigs: BasicConfig[]
  locationConfigs: ServerLocation[]
}

export interface ServerLocation {
  uri: string
  modifier: string
  basicConfigs: BasicConfig[]
}

export interface HttpStreamConfig {
  name: string
  basicConfigs: BasicConfig[]

}

export interface StreamServerConfig {
  listen: string
  basicConfigs: BasicConfig[]
}
